<?php
/**
 * User: 1971229701@qq.com
 * Date: 2020/11/6/006
 * Time: 10:26
 */

namespace app\index\controller;


use app\Index\logic\ListsLogic;
use think\Request;
use think\Db;

class Lists extends Base
{
    public function index($title = '', $price = '', $pailiang = '', $qudong = '')
    {
        $r = (new ListsLogic())->listing($title, $price, $pailiang, $qudong);
        $cartype = Db::table('cate')->order('sort')->select();
        $list =array();
        foreach( $cartype as $key=>$val) {
            $list[] = Db::table('lists')->where(array('pid'=>$val['id']))->order('sort')->select();
        }

        $this->assign('list',$list);
        $this->assign('cartype', $cartype);
       // $this->assign('clist', $r['cList']);
        $this->assign('alist', $r['aList']);
        $this->assign('cate_list', $r['cate_list']);
        $this->assign('price', $r['price']);
        $this->assign('pailiang', $r['pailiang']);
        $this->assign('qudong', $r['qudong']);
        $this->assign('web_title', '车型展示');
        return $this->fetch();
    }

    // 车型详情
    public function detail($id = 1)
    {

        $r = (new ListsLogic())->detail($id);
        $this->assign('info',$r['info']);
        $this->assign('banner',$r['banner']);
        $this->assign('liangdian',$r['liangdian']);
        $this->assign('list',$r['list']);
        $this->assign('web_title','车型详情');
        return $this->fetch();
    }

    public function search(Request $request)
    {
        $data = array_filter($request->post());

        $r = (new ListsLogic())->search($data);
        return apiReturnSuc($r);
    }
}